{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- sku -->
<link href="__STATIC__/css/sku.css" rel="stylesheet" type="text/css">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">

                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>创建轮胎订单
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm" onsubmit="return check()">




                                    <!--<div class="divider-dashed"></div>-->

                                    <!--<div class="form-group">-->
                                    <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">成 本 价：</label>-->
                                    <!--<div class="col-md-1 col-sm-6 col-xs-12">-->
                                    <!--<input type="text" placeholder="请输入成本价"-->
                                    <!--class="form-control col-md-7 col-xs-12" name="cost_price"-->
                                    <!--value="{$item.cost_price|default=''}"-->
                                    <!--&gt;-->
                                    <!--</div>-->
                                    <!--</div>-->


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">代存编码：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">

                                            <input  style="width: 100%" type="text" name="order_number" value="{$item.order_number ?: order_number()}" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">金额：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">

                                            <input  style="width: 100%" type="text" name="amount" value="{$item.amount|default=''}" {if condition="request()->action() eq 'update'"} readonly{/if}>
                                        </div>
                                    </div>



                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">寄存门店：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" style="margin-top: 8px;">
                                            {if condition="session('auding_status') eq 2"}
                                            <select name="shop_id" class="select2_single" readonly
                                                    style="width:100%;" tabindex="-1"
                                                    datatype="*"
                                                    nullmsg="请选择寄存门店！" errormsg="请选择寄存门店！"
                                            >
                                                {foreach :model('shop')->where('status',1)->where('auding_status',2)->where('is_delete',1)->select() as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>{$vo.shop_title}</option>
                                                {/foreach}
                                                {/volist}
                                            </select>
                                            {else/}
                                            {foreach :model('shop')->where('status',1)->where('auding_status',2)->where('is_delete',1)->where('id',$shop_id)->select() as $key=>$vo }
                                            {$vo.shop_title}
                                            {/foreach}
                                            {/if}

                                        </div>
                                    </div>
                                    <!-- Datatables-->

                        <script>

                        </script>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">用户账号：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input style="width: 290px;" type="text" placeholder="请填写用户账号" {if condition="request()->action() eq 'update'"} readonly{/if}
                                                   class="form-control col-md-7 col-xs-12" name="username"
                                                   value="{$item.username|default=''}" datatype="*" nullmsg="请填写用户账号"
                                            ><a style="float: right"  class="btn btn-primary" id="parentIframe">查询</a>
                                        </div>
                                    </div>
                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">用户姓名：</label>-->
                                        <!--<div class="col-md-3 col-sm-6 col-xs-12">-->
                                            <!--<input type="text" placeholder="请填写用户姓名" {if condition="request()->action() eq 'update'"} readonly{/if}-->
                                                   <!--class="form-control col-md-7 col-xs-12" name="nickname"-->
                                                   <!--value="{$item.nickname|default=''}" datatype="*" nullmsg="请填写用户姓名"-->
                                            <!--&gt;-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">使用区间时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请选择时间区间" {if condition="request()->action() eq 'update'"} readonly{/if}
                                                   class="form-control col-md-7 col-xs-12" name="interval_timer"
                                                   id="interval_timer"
                                                   {present name="$item.id"}
                                                   value="{$item.start_time} / {$item.end_time}"
                                                   {/present}
                                            datatype="*"
                                            nullmsg="请选择时间区间" errormsg="请选择时间区间！"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">上传组图：【720*365】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">

                                            <div class="uploader white">
                                                <input type="button" id="logo_upload_btn" class="button" value="批量上传" {if condition="request()->action() eq 'update'"} disabled{/if}/>
                                            </div>

                                            <div id="logo_upload_area" style='width:80%'>
                                                <div id='photos_area' class="photos_area clearfix">

                                                    {if condition="($Request.action eq 'update') && ($item.multi_pic neq 'N;')"}
                                                    {foreach :unserialize($item['multi_pic']) as $picValue}
                                                    <div class="item">
                                                        <input type="hidden" name="picArr[]" value="{$picValue}">
                                                        <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">
                                                        <div class="operate">
                                                            <i class="toleft">左移</i>
                                                            <i class="toright">右移</i>
                                                            <i class="del">删除</i>
                                                        </div>
                                                    </div>
                                                    {/foreach}
                                                    {/if}

                                                </div>
                                                <div class="alert alert-success" role="alert"
                                                     style="margin:10px 0;"><strong><span
                                                        class="glyphicon glyphicon-flag"></span>点击批量上传按钮上传多张图片:</strong>&nbsp;&nbsp;单张图片大小不超过500KB,格式为jpg,png,gif,jpeg
                                                </div>

                                            </div>

                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">备注：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <textarea type="text" placeholder="请填写备注" style="width: 380px;height: 150px;" {if condition="request()->action() eq 'update'"} readonly{/if}
                                                   class="form-control col-md-7 col-xs-12" name="explain"

                                            >{$item.explain|default=''}</textarea>
                                        </div>
                                    </div>
                                    {if condition="request()->action() eq 'create'"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订单状态：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <label class="radio_box">
                                                <input type="radio" name="status" id="status_1" class="cartradio"
                                                       value="6"
                                                       datatype="*"
                                                       nullmsg="请选择订单状态！" errormsg="请选择订单状态！"
                                                       {eq name='item.status|default=""' value='6' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="status_1"></label>
                                                <span>免费寄存(进行中)</span>
                                                &nbsp;&nbsp;
                                            </label>
                                            <label class="radio_box">
                                                <input type="radio" name="status" id="status_2" class="cartradio"
                                                       value="1"
                                                       datatype="*"
                                                       nullmsg="请选择订单状态！" errormsg="请选择订单状态！"
                                                       {eq name='item.status|default=""' value='1' }
                                                       checked
                                                       {/eq}
                                                >&nbsp;&nbsp;
                                                <label for="status_2"></label>
                                                <span>付费寄存(代付款)</span>
                                                &nbsp;&nbsp;
                                            </label>
                                        </div>
                                    </div>
                                    {else/}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订单状态：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.status|default='无'"}
                                            {case 50}等待沟通{/case}
                                            {case 1}未支付{/case}
                                            {case 6}进行中--{switch name="item.code"}{case 1}等待验证{/case}{case 2} 已验证{/case}{/switch}{/case}
                                            {case 5}已确认{/case}
                                            {case 4}已评价{/case}
                                            {case 10}退款中{/case}
                                            {case 11}退款成功{/case}
                                            {case 12}退款失败{/case}
                                            {case 20}取消订单{/case}
                                            {/switch}
                                            <br/>

                                        </div>

                                    </div>
                                    {/if}

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {present name="$item.id"}
                                            <input type="hidden" name="id" value="{$item.id}">

                                            {/present}
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- select -->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>

<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">



</script>
<script>
    $('#parentIframe').click(function(){

        var title = $('[name="username"]').val();
        if(!title){
            layer.msg('用户名或车牌号不能为空');
            return;
        }
        layer.open({
            type: 2,
            area: ['700px', '450px'],
            fixed: false, //不固定
            maxmin: true,
            content: 'http://lihai.xmdonkey.com/index.php/console/member/title?title='+title
        });
    });

    // 组图排序 删除图片
    $(".toleft").live("click", function () {
        var item = $(this).parent().parent(".item");
        var item_left = item.prev(".item");
        if ($("#photos_area").children(".item").length >= 2) {
            if (item_left.length == 0) {
                item.insertAfter($("#photos_area").children(".item:last"));
            } else {
                item.insertBefore(item_left);
            }
        }

    })

    $(".toright").live("click", function () {
        var item = $(this).parent().parent(".item");
        var item_right = item.next(".item");
        if ($("#photos_area").children(".item").length >= 2) {
            if (item_right.length == 0) {
                item.insertBefore($("#photos_area").children(".item:first"));
            } else {
                item.insertAfter(item_right);
            }
        }
    })

    $(".del").live("click", function () {
        $(this).parent().parent(".item").remove();
    })
    // validform
    $(function () {
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });


        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});

        // select2



        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                }else{
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "/index.php/client/shop_goods/uploadarr.html",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '500kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
//                alert(item.length);
//                if(item.length >= 2){
//                    alert('最多只能上传2张图片');
//                    return false;
//                }
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();


        function delThisTr(trobj)
        {
            trobj.parent().parent().remove();
        }

        function delThis(trobj,id)
        {
            if(confirm('确认删除？')){
                $.ajax({
                    url : '{:url("ShopGoodsFlag/destroy")}',
                    data:{'id':id},
                    dataType:'html',
                    success:function(data){
                        if(data == 'true'){
                            layer.msg('删除成功');
                            trobj.parent().parent().remove();
                        }else{
                            layer.msg('网络繁忙,请重试');
                        }
                    }
                });
            }
        }
        $(".addNewTr").click(function(){
            str = '<tr><td><input type="text" name="nameAttr[]" style="width:100px;"/></td>' +
                '<td><input type="text" name="valueAttr[]" style="width:100px;" /></td>' +
                '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
            $("#fieldtr").append(str);
        });






</script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<script type="text/javascript">
    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    var str = '<a href="http://www.baidu.com">链接111111111</a> ';
    var reg1 = /href=\"(.+)\"/g;
    var reg2 = /\">(.+)<\/a>/g;
    var retVal1 = reg1.exec(str);
    var retVal2 = reg2.exec(str);
    //alert(retVal1[1]);
    //alert(retVal2[1]);
</script>
<script src="__STATIC__/js/sku.js"></script>
</body>

</html>
